package com.cy.mall.web.comm;

import com.cy.mall.comm.constant.Constants;
import com.cy.mall.model.Result;
import com.cy.mall.model.enums.IdCardType;
import com.cy.mall.service.comm.OcrIdCardService;
import com.cy.mall.service.comm.impl.OssFileUploadServiceImpl;
import com.cy.mall.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Description 身份证ocr识别
 * @Author tanyilin
 * @Date 2019/6/16 15:26
 */
@RestController
@RequestMapping("/ocr/id/card")
@Api(tags = "身份证ocr识别")
public class OcrIdCardController extends BaseController {

    @Autowired
    private OcrIdCardService ocrIdCardService;
    @Autowired
    private OssFileUploadServiceImpl ossFileUploadService;

    @ApiOperation("测试身份证ocr识别")
    @GetMapping("/do/test")
    public Result testOcrIdCard(@RequestParam(value = "image") String image, @RequestParam(value = "idCardType") IdCardType idCardType) {

        Result<Map<String, Object>> result = ocrIdCardService.doOcrIdCard(ossFileUploadService.getFileUrl(image, Constants.BUCKETNAME), idCardType);
        return result;
    }

}
